<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-table
        v-loading="listLoading"
        :data="tableData.list"
        style="width: 100%"
        :header-cell-style="{ fontWeight: 'bold' }"
      >
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column prop="adminId" :label="$t('guanLiYuan')+' id'" width="80" />
        <el-table-column prop="adminAccount" :label="$t('guanLiYuanZhangHao')" width="120" />
        <el-table-column prop="status" :label="$t('caoZuoZhuangTai')" width="100">
          <template slot-scope="scope">
            <el-tag :type="scope.row.status ? 'danger' : ''">{{ scope.row.status ? $t('yiChang') : $t('zhengChang') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="description"
          :label="$t('jieKouMiaoShu')"
          width="140"
          :show-overflow-tooltip="true"
        />
        <el-table-column prop="createTime" :label="$t('caoZuoShiJian')" width="120" :show-overflow-tooltip="true" />
        <el-table-column prop="ip" :label="$t('zhuJiDiZhi')" width="120" :show-overflow-tooltip="true" />
        <el-table-column prop="method" :label="$t('fangFaMingCheng')" width="180" :show-overflow-tooltip="true" />
        <el-table-column prop="url" :label="$t('qingQiuUrl')" width="180" :show-overflow-tooltip="true" />
        <el-table-column prop="methodType" :label="$t('qingQiuLeiXing')" width="100" />
        <el-table-column prop="requestMethod" :label="$t('qingQiuFangShi')" width="100" />
        <el-table-column
          prop="requestParam"
          :label="$t('qingQiuCanShu')"
          width="150"
          :show-overflow-tooltip="true"
        />
        <el-table-column prop="result" :label="$t('fanHuiCanShu')" width="180" :show-overflow-tooltip="true" />
        <el-table-column prop="errorMsg" :label="$t('cuoWuXiaoXi')" width="180" :show-overflow-tooltip="true" />
      </el-table>
      <el-pagination
        :page-sizes="[20, 30, 40, 60]"
        :page-size="tableFrom.limit"
        :current-page="tableFrom.page"
        layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.total"
        @size-change="handleSizeChange"
        @current-change="pageChange"
      />
    </el-card>
  </div>
</template>
<script>
import { sensitiveListApi } from '@/api/systemadmin'
export default {
  data() {
    return {
      tableData: {},
      tableFrom: {
        page: 1,
        limit: 20
      },
      listLoading: false
    }
  },
  mounted() {
    this.getLogList()
  },
  methods: {
    getLogList() {
      this.listLoading = true
      sensitiveListApi(this.tableFrom).then((res) => {
        this.tableData = res
        this.listLoading = false
      })
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val
      this.getLogList()
    },
    pageChange(page) {
      this.tableFrom.page = page
      this.getLogList()
    }
  }
}
</script>
